{
  "properties" : { },
  "id" : "a2ea56ce9ce345fd9e9160acf6c736ed",
  "script" : null,
  "groupId" : "74af8e1135d2474eb9b6b4081e6d5967",
  "name" : "历史版本恢复",
  "createTime" : 1727071030364,
  "updateTime" : 1726654202658,
  "lock" : "0",
  "createBy" : "ndmp",
  "updateBy" : "ndmp",
  "path" : "recovery",
  "method" : "POST",
  "parameters" : [ ],
  "options" : [ ],
  "requestBody" : "{\r\n\"id\": \"1836312833029328896\"\r\n\r\n}",
  "headers" : [ ],
  "paths" : [ ],
  "responseBody" : "{\n    \"status\": 200,\n    \"message\": \"success\",\n    \"data\": true\n}",
  "description" : "",
  "requestBodyDefinition" : {
    "name" : null,
    "value" : null,
    "description" : null,
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  },
  "responseBodyDefinition" : {
    "name" : null,
    "value" : null,
    "description" : null,
    "required" : false,
    "dataType" : "String",
    "type" : null,
    "defaultValue" : null,
    "validateType" : null,
    "error" : null,
    "expression" : null,
    "children" : null
  }
}
================================
 import com.kd.ndmp.util.IdUtil
 import org.springframework.util.CollectionUtils
 var msg = db.table("ndmp_topo_msg_history").where().eq("id", body.id).selectOne()
 var topoMsg = {
     "gplot": msg.topology,
     "lastdate": DateUtil.formatDateTime(new Date()),
     "deptid": msg.deptId


 }

 db.table("ndmp_topo_msg").primary("deptid").update(topoMsg)


 msg.updateDate = new Date();
 msg.id = IdUtil.getSnowflakeNextId()

 db.table("ndmp_topo_msg_history").insert(msg)


 // 删除大于10条的记录
 List updateDate = db.select("""
 SELECT update_date FROM ndmp_topo_msg_history
        WHERE 1 = 1
        <if test="deptId != null">
            and dept_id = #{msg.deptId}
        </if>
        ORDER BY update_date desc LIMIT 9,1""")

 if (!CollectionUtils.isEmpty(updateDate)) {
     var update_date = updateDate[0].get("updateDate")
     db.update("""
        DELETE FROM ndmp_topo_msg_history
        WHERE 1 = 1
        <if test="deptId != null">
            and dept_id = #{msg.deptId}
        </if>
        <if test="update_date != null and update_date != ''">
            and update_date &lt; #{update_date}
        </if>
     """)

 }
 return true